#include "MOTION.h"



//驱动轮引脚设置
MOTION::MOTION(int left1,int left2,int right1,int right2){
  
Left1 = left1;
Left2 = left2;
Right1 = right1;
Right2 = right2;
}

//驱动轮引脚初始化
void MOTION::initWheel() {
  pinMode(Left1, OUTPUT);
  pinMode(Left2, OUTPUT);
  pinMode(Right1, OUTPUT);
  pinMode(Right2, OUTPUT);
}

//停止
void MOTION::goStop() { 
  analogWrite(Right2, 0);
  analogWrite(Right1, 0);
  analogWrite(Left2, 0);
  analogWrite(Left1, 0);
}

//后退
void MOTION::goBack(int speed) {   

  analogWrite(Right1, 0);
  analogWrite(Right2, speed);
  analogWrite(Left1, 0);
  analogWrite(Left2, speed);
}

//前进
void MOTION::goForward(int outputR,int outputL) {

  analogWrite(Right1, outputR);
  analogWrite(Right2, 0);
  analogWrite(Left1, outputL);
  analogWrite(Left2, 0);
}

//左转
void MOTION::turnLeft(int speed) { 
  analogWrite(Right1, speed);
  analogWrite(Right2, 0);
  analogWrite(Left1, 0);
  analogWrite(Left2, 0);
}

//右转
void MOTION::turnRight(int speed) {   
  analogWrite(Right1, 0);
  analogWrite(Right2, 0);
  analogWrite(Left1, speed);
  analogWrite(Left2, 0);

}

//原地掉头（从右边）
void MOTION::goReboundRight(int speed) {   
  analogWrite(Right1, 0);
  analogWrite(Right2, speed);
  analogWrite(Left1, speed);
  analogWrite(Left2, 0);
}

//原地掉头（从左边）
void MOTION::goReboundLeft(int speed) {   
  analogWrite(Right1, speed);
  analogWrite(Right2, 0);
  analogWrite(Left1, 0);
  analogWrite(Left2, speed);
}
